package iscript.gameFramework.IsoLibarys.display 
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.display.Sprite;
	/**
	 * ...
	 * @author raymond
	 */
	public class IsoBitmapData 
	{
		
		public function IsoBitmapData() 
		{
			
		}
		
		static private var _normal:BitmapData; 
		static private var _hover:BitmapData; 
		
		static private var _normalShape:Shape; 
		static private var _hoverShape:Shape; 
		
		static private var _graphicsWidth:Number=0; 
		static private var _graphicsHeight:Number=0; 
		
		static public function initialize(w:Number, h:Number):void {
			_graphicsWidth = w;
			_graphicsHeight = h;
			}
		 
		 static public function clearShape(target:Shape):void{}
			
		static public function normalShape(target:Shape):void {
			if (_graphicsWidth == 0 || _graphicsHeight == 0) { throw new Error("initialize  width && height") }
				 var _gridGemo:Shape = target;
				 _gridGemo.graphics.clear();				 
				 _gridGemo.graphics.beginFill(0xFFFFFF, 0.005);
				 _gridGemo.graphics.lineStyle(1, 0x990000, 1);
				 _gridGemo.graphics.moveTo(_graphicsWidth / 2, 0);
				 _gridGemo.graphics.lineTo(0, _graphicsHeight / 2);
				 _gridGemo.graphics.lineTo(_graphicsWidth / 2, _graphicsHeight);
				 _gridGemo.graphics.lineTo(_graphicsWidth, _graphicsHeight / 2);
				 _gridGemo.graphics.lineTo(_graphicsWidth / 2, 0);	
				 _gridGemo.graphics.endFill();
			}	
			
		 static public function hoverShape(target:Shape):void {
			if (_graphicsWidth == 0 || _graphicsHeight == 0) { throw new Error("initialize  width && height") }
				 var _gridGemo:Shape = target;
 				 _gridGemo.graphics.clear();				 
				 _gridGemo.graphics.beginFill(0x990000, 0.3);
				 _gridGemo.graphics.lineStyle(1, 0x990000, 1);
				 _gridGemo.graphics.moveTo(_graphicsWidth / 2, 0);
				 _gridGemo.graphics.lineTo(0, _graphicsHeight / 2);
				 _gridGemo.graphics.lineTo(_graphicsWidth / 2, _graphicsHeight);
				 _gridGemo.graphics.lineTo(_graphicsWidth, _graphicsHeight / 2);
				 _gridGemo.graphics.lineTo(_graphicsWidth / 2, 0);	
				 _gridGemo.graphics.endFill();				  
			}
			
			
		static public function normal():BitmapData {
			if (_graphicsWidth == 0 || _graphicsHeight == 0) { throw new Error("initialize  width && height") }
			if (_normal != null) return _normal;
				 var _gridGemo:Shape = new Shape();
 				 _gridGemo.graphics.clear();				 
				 _gridGemo.graphics.beginFill(0xFFFFFF, 0.005);
				 _gridGemo.graphics.lineStyle(1, 0x990000, 1);
				 _gridGemo.graphics.moveTo(_graphicsWidth / 2, 0);
				 _gridGemo.graphics.lineTo(0, _graphicsHeight / 2);
				 _gridGemo.graphics.lineTo(_graphicsWidth / 2, _graphicsHeight);
				 _gridGemo.graphics.lineTo(_graphicsWidth, _graphicsHeight / 2);
				 _gridGemo.graphics.lineTo(_graphicsWidth / 2, 0);	
				 _gridGemo.graphics.endFill();
				 
				 var normalGrid:BitmapData =  new BitmapData(_graphicsWidth+2, _graphicsHeight+2, true, 0xFFFFFF);
				 normalGrid.draw(_gridGemo);
				 _gridGemo.graphics.clear(); 
				 _normal = normalGrid;	 
			     return  _normal;
			}
			 
			 
		static public function hover():BitmapData {
			if (_graphicsWidth == 0 || _graphicsHeight == 0) { throw new Error("initialize  width && height") }
			if (_hover != null) return _hover;
				 var _gridGemo:Shape = new Shape();
 				 _gridGemo.graphics.clear();				 
				 _gridGemo.graphics.beginFill(0x990000, 0.3);
				 _gridGemo.graphics.lineStyle(1, 0x990000, 1);
				 _gridGemo.graphics.moveTo(_graphicsWidth / 2, 0);
				 _gridGemo.graphics.lineTo(0, _graphicsHeight / 2);
				 _gridGemo.graphics.lineTo(_graphicsWidth / 2, _graphicsHeight);
				 _gridGemo.graphics.lineTo(_graphicsWidth, _graphicsHeight / 2);
				 _gridGemo.graphics.lineTo(_graphicsWidth / 2, 0);	
				 _gridGemo.graphics.endFill();
				 
				 var _hoverGrid:BitmapData =  new BitmapData(_graphicsWidth+2, _graphicsHeight+2, true, 0xFFFFFF);
				 _hoverGrid.draw(_gridGemo);
				 _gridGemo.graphics.clear();	 
				 
				 _hover = _hoverGrid;	 
			     return  _hover;
			}
	}

}